<?php

class  dates{
   
    public static function dateFormToBase($date){
        if($date != ''){
        $dates= explode(' ', $date);
        $datesFin=  explode('/', $dates[0]);
        $year = $datesFin[2];
        $month = $datesFin[1];
        $day = $datesFin[0];
        if(count($dates)==1)
          return date('Y-m-d',mktime(0,0,0,$month ,$day, $year));
        else{
            $heureFin=split(':', $dates[1]);
            $heure=$heureFin[0];
            $menute=$heureFin[1];
            return date('Y-m-d H:i',mktime($heure,$menute,0,$month ,$day, $year));
        }
          }
        return '';
    }
    public static function dateForm($date,$heur=false){
        if($date != ''){
        $date=  explode ('-', $date);
        $year = $date[0];
        $month = $date[1];
        $day = $date[2];
        return date('d/m/Y',mktime(0,0,0,$month,$day , $year));}
        return '';
    }
    public static function dateHeurForm($date){
        if($date != ''){
        $dates=  explode(' ', $date);
        $datesFin=  explode('-', $dates[0]);
        $year = $datesFin[0];
        $month = $datesFin[1];
        $day = $datesFin[2];
        $heureFin= explode(':',$dates[1]);
        $heure=$heureFin[0];
        $menute=$heureFin[1];
        
        return date('d/m/Y H:i',mktime($day,$month , $year,$heure,$menute));}
        return '';
    }
    public static function dateFrancais($date){
        $datefr='';
        if($date != ''){
        
        $dates=split(' ', $date);
        $datesFin=  split('-', $dates[0]);
        $year = $datesFin[0];
        $month = $datesFin[1];
        $month=intval($month);
        $day = $datesFin[2];
        $day=  intval($day);
        $da=strftime('%w',strtotime($day.'/28/2002'));
       
        $Jour = array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
        $Mois = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
        $datefr = $Jour[$da] . " " . $day . " " . $Mois[$month] . " " . $year;
        }
        return $datefr;
    }
    public static function heureFrancais($date){
        $datefr='';
        if($date != ''){
        $dates=split(' ', $date);
        $datesFin=  split(':', $dates[1]);
         $heur = $datesFin[0];
        $minute = $datesFin[1];
        $datefr=$heur.':'.$minute;
    }
    return $datefr;
    }
}
?>
